import requests

from test_data import content, keywords, title, wordlimit, wordlimit2

address = "http://authiwrite.unipus.cn"
task_id_url = address + "/iwrite/check_all"
result_url = address + "/iwrite/result/check_all"

app_key = 203768948
app_secret = "q17tvy61k60ehqlsrjwvl1oa6szn41gg"
app_code = "f61f7034162e4d9dbe10e6de49006eac"

headers = {"Authorization": f"APPCODE {app_code}",
           "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}

body = {"content": content,
        "keywords": keywords,
        "title": title,
        "wordlimit": wordlimit,
        "wordlimit2": wordlimit2}


def get_task_id():
    """
    获取任务id
    content
    title
    keywords
    wordlimit
    wordlimit2
    """
    res = requests.post(task_id_url, headers=headers, data=body)
    print("status codes: ", res.status_code)

    if res.status_code == 200:
        pass
    elif res.status_code == 410:
        pass
    elif res.status_code == 202:
        print("获取id成功")
        return res.content


def get_result(task_id):
    res = requests.get(result_url, params={"id": task_id})
    # todo 状态码判断


if __name__ == '__main__':
    task_id = get_task_id()
